<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('公共字段管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>字段名称：</label>
                                <input type="text" name="na"/>
                            </li>
                            <li>
                                <label>维度类型：</label>
                                <select name="sdDimtp" th:with="type=${@baseSd.getItem('dim_type')}">
                                    <option value=""></option>
                                    <option th:each="item : ${type}" th:text="${item.na}" th:value="${item.cd}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="createAllDimTb()">
                    <i class="glyphicon glyphicon-hand-up"></i> 一键建表
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "md/med/pubfld";

        function createAllDimTb() {
            $.ajax({
                url: prefix+'/createAllDimTable',
                type: 'get',
                dataType: 'json',
                success: function (result) {

                    if(result.code==0) {
                        $.modal.alertSuccess(result.msg);
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $("#bootstrap-table").bootstrapTable('refresh');
                }
            });
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "公共字段管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'idPubfld',
                    title: '字段编码'
                },
                {
                    field: 'na',
                    title: '字段名称'
                },
                {
                    field: 'naJavatp',
                    title: 'JAVA字段类型'
                },
                {
                    field: 'numLth',
                    title: '长度'
                },
                {
                    field: 'numPrec',
                    title: '精度'
                },
                {
                    field: 'naDimtp',
                    title: '维度类型'
                },
                {
                    field: 'cdTbDim',
                    title: '维度表'
                },
                {
                    field: 'des',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.idPubfld + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idPubfld + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>